package top.jacktgq.lock.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

import top.jacktgq.utils.LogUtils;
/**
 * 
 * @Title: TestReentrantLock.java 
 * @Package top.jacktgq.lock 
 * @Description: 测试ReentrantLock：可重入
 * @author CandyWall   
 * @date 2020年11月1日 下午5:49:07 
 * @version V1.0
 */
public class Demo1 {
	private static ReentrantLock lock = new ReentrantLock();
	public static void main(String[] args) {
		lock.lock();
		try {
			LogUtils.log("Demo1", "enter main");
			m1();
		} finally {
			lock.unlock();
		}
	}
	
	private static void m1() {
		lock.lock();
		try {
			LogUtils.log("Demo1", "enter m1");
			m2();
		} finally {
			lock.unlock();
		}
	}
	
	private static void m2() {
		lock.lock();
		try {
			LogUtils.log("Demo1", "enter m2");
		} finally {
			lock.unlock();
		}
	}
}
